﻿using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json.Linq;
using ProjScan.ScanRule.CodeAnalysis;
using ProjScan.Tools;

namespace ProjScan.ScanRule.RuleData
{
	// Token: 0x020001B6 RID: 438
	internal class CSCheckRuleData : RuleData
	{
		// Token: 0x06000E72 RID: 3698 RVA: 0x0000724D File Offset: 0x0000544D
		public override void Init()
		{
			this.targetsDictionary = new Dictionary<string, CSCheckTarget>();
		}

		// Token: 0x06000E73 RID: 3699 RVA: 0x00041CBC File Offset: 0x0003FEBC
		public override void LoadRuleData()
		{
			string path = Path.Combine(ToolsHelper.GetLocationPath(), "CSCheckRuleData.json");
			bool flag = !File.Exists(path);
			if (flag)
			{
				ScanLog.Instance.LogInfo("CSCheckRuleData Json File does not exist.");
			}
			else
			{
				string text = File.ReadAllText(path);
				JArray jarray = JArray.Parse(text);
				foreach (JToken jtoken in jarray)
				{
					JObject jobject = (JObject)jtoken;
					CSCheckTarget cscheckTarget = new CSCheckTarget();
					cscheckTarget.id = (int)jobject["id"];
					cscheckTarget.method = (string)jobject["method"];
					cscheckTarget.area = (string)jobject["area"];
					JArray jarray2 = (JArray)jobject["types"];
					foreach (JToken jtoken2 in jarray2)
					{
						JValue jvalue = (JValue)jtoken2;
						cscheckTarget.AddType((string)jvalue);
					}
					cscheckTarget.AddMethod(cscheckTarget.method);
					bool flag2 = jobject["methods"] != null;
					if (flag2)
					{
						JArray jarray3 = (JArray)jobject["methods"];
						foreach (JToken jtoken3 in jarray3)
						{
							JValue jvalue2 = (JValue)jtoken3;
							cscheckTarget.AddMethod((string)jvalue2);
						}
					}
					this.targetsDictionary[cscheckTarget.method] = cscheckTarget;
				}
			}
		}

		// Token: 0x040008DC RID: 2268
		public Dictionary<string, CSCheckTarget> targetsDictionary;
	}
}
